//
//  HEReagentCheckCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/10.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEReagentCheckCell.h"

@interface HEReagentCheckCell ()
@property (nonatomic, strong) UILabel *titleLb;

@property (nonatomic, strong) UILabel *checkItemLb;
@property (nonatomic, strong) UILabel *acTimeLb;
@property (nonatomic, strong) UILabel *contentLb;

@end

@implementation HEReagentCheckCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = CLightGrayColor;

        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
 
    warp.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp.layer.shadowOffset = CGSizeMake(0,5);
    warp.layer.shadowOpacity = 1;
    warp.layer.shadowRadius = 6;
    warp.layer.cornerRadius = 10;
 
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-5);
    }];
    
    
    // head
    
    UIView *blueLine = [UIView new];
    blueLine.backgroundColor = CNavBgColor;
    [warp addSubview:blueLine];
    
    _titleLb = [UILabel new];
    _titleLb.text = @"检测报告";
    _titleLb.font = DYBlodFont(18);
    [warp addSubview:_titleLb];
 
    
    UIView *headBottomLine = [UIView new];
    headBottomLine.backgroundColor = CSplitLineColor;
    [warp addSubview: headBottomLine];
    
    [blueLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.left.equalTo(warp).offset(10);
        make.width.offset(3);
        make.height.offset(20);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).offset(15);
        make.left.equalTo(blueLine.mas_right).offset(10);
        make.right.equalTo(warp).offset(-15);
    }];
  
    // middle
    _checkItemLb = [UILabel new];
    _checkItemLb.text = @"-";
    _checkItemLb.font = DYFont(16);
    [warp addSubview: _checkItemLb];
     
    _contentLb = [UILabel new];
    _contentLb.text = @"-";
    _contentLb.font = DYFont(16);
    _contentLb.textColor = CNavDargGrayColor;
    _contentLb.numberOfLines = 2;
    [warp addSubview: _contentLb];
  
    UILabel *timeTitlLb = [UILabel new];
    timeTitlLb.text = @"检测时间：";
    timeTitlLb.font = DYFont(16);
    timeTitlLb.textColor = CNavDargGrayColor;
    [warp addSubview: timeTitlLb];
       
    
    _acTimeLb = [UILabel new];
    _acTimeLb.text = @"-";
    _acTimeLb.font = DYFont(16);
    _acTimeLb.textColor = CNavDargGrayColor;
    [warp addSubview: _acTimeLb];
    
    [_checkItemLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
    }];
    
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_checkItemLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
    }];
      
    
    // title -
    [timeTitlLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_contentLb.mas_bottom).offset(10);
        make.left.equalTo(_checkItemLb.mas_left);
    }];
    [timeTitlLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  
    // cnt --
    [_acTimeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_contentLb.mas_bottom).offset(10);
        make.left.equalTo(timeTitlLb.mas_right);
        make.right.equalTo(warp).offset(-10);
    }];
     
    
    //  footer
    UIView *footerTopLine = [UIView new];
    footerTopLine.backgroundColor = CSplitLineColor;
    [warp addSubview: footerTopLine];
    [footerTopLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_acTimeLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
        make.height.offset(1);
    }];
    
    UILabel *checkLb = [UILabel new];
    checkLb.text = @"立即查看";
    checkLb.font = DYFont(16);
    [warp addSubview: checkLb];
    
    [checkLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(footerTopLine.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.bottom.equalTo(warp.mas_bottom).offset(-15);
    }];
    
    UIImageView *_arrowView = [UIImageView new];
    _arrowView.contentMode = UIViewContentModeScaleAspectFill;
    _arrowView.image = IMAGE_NAMED(@"go_gray");
    [warp addSubview:_arrowView];
    
    [_arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(checkLb);
        make.right.equalTo(warp).mas_offset(-15);
        make.width.mas_offset(8);
        make.height.mas_offset(12);
    }];
}

- (void)setModel:(HECheckItemModel *)model {
    _model = model;
    
    _checkItemLb.text = model.projectName;
    _contentLb.text = model.summary;
    _acTimeLb.text = model.create_date;
}
 

@end
